//
//  LeftCell.m
//  当当网
//
//  Created by app12 on 15/7/19.
//  Copyright (c) 2015年 孙萍. All rights reserved.
//

#import "LeftViewCell.h"

//背景色
#define  SPColor(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]

@interface LeftViewCell()
@property(nonatomic, weak)UIButton* selectedBtn;
@property(nonatomic, weak)UIView* selectedView;
@end

@implementation LeftViewCell

+(instancetype)leftViewCell{
    
    return [[NSBundle mainBundle]loadNibNamed:@"LeftViewCell" owner:nil options:nil][0];
}


- (IBAction)chooseCategorys:(id)sender {
    UIButton* btn = (UIButton*)sender;
    if ([self.delegate respondsToSelector:@selector(changeChoice:)]) {
        [self.delegate changeChoice:btn.tag-101];
    }

}

- (void)setSelected:(BOOL)selected tag:(NSInteger)tag{
    if (selected && (tag == 0)) {
        self.nameBtn.selected = YES;
        self.nameBtn.backgroundColor = [UIColor whiteColor];
        self.redImage.hidden = NO;
        return;
    }
    else if (selected){
        self.nameBtn.selected = YES;
        self.nameBtn.backgroundColor = [UIColor whiteColor];
        self.redImage.hidden = NO;
        return;
    }
        self.nameBtn.selected = NO;
        self.nameBtn.backgroundColor = SPColor(244, 244, 244);
        self.redImage.hidden = YES;
    
}

@end
